package com.office.test;

import com.office.bean.Depart;
import com.office.bean.Emp;
import com.office.service.DepartService;
import com.office.service.EmpService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.util.List;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:applicationContext.xml")
public class test {

    @Autowired
    EmpService empService;
    @Autowired
    DepartService departService;

    @Test
    public void test1(){
        Emp emp=new Emp();
        emp.setNo("bruce");
        emp.setPass("admin");
        Emp loginUser = empService.login(emp);
        System.out.println(loginUser);
    }

    @Test
    public void test2(){
        for (int i = 0 ;i < 100 ;i++){
            Depart depart = new Depart("技术部"+i,"2007-02-25");
            int i1 = departService.addDepart(depart);
        }
    }

    @Test
    public void findEmps(){
        List<Emp> emps = empService.findEmps();
        for (Emp emp : emps) {
            System.out.println(emp);
        }
    }



}
